package com.atxiaodei;

import com.atxiaodei.opcode.OpCode;
import com.atxiaodei.protocol.MessageRecord;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelInboundHandlerAdapter;
import lombok.extern.slf4j.Slf4j;


@Slf4j
public class ServerHandler extends ChannelInboundHandlerAdapter {
    @Override
    public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
        //ServerHandler， 应该是SocketChannel触发的。
        MessageRecord record=(MessageRecord)msg;
        log.info("Server Receive Message:"+record);
        record.setBody("Server Response Message");
        record.getHeader().setReqType(OpCode.RES.code());
        ctx.writeAndFlush(record);
//        super.channelRead(ctx, msg);
    }
}
